const koa = require('koa')
const cors = require('koa-cors')
const bodyparser = require('koa-bodyparser')

const {APP_PORT} = require('./config/config.default')
const routerMiddleware = require('./router/index')
const {product,sync,user} = require('./model/use.model')

const app = new koa()

app.use(cors())
app.use(bodyparser())
app.use(routerMiddleware())
sync().then(async()=>{
    product.create({
        productName: 'iPhone 13 Pro 256G 远峰蓝',
        price: 8399,
        stock: 500,
    })

    user.create({
        user_name:'zb',
        password:'12345',
    })
})

let a = product.findAll({
    where:{
        id:1
    }
})


app.listen(APP_PORT,()=>{
    console.log(`http://localhost:${APP_PORT}`);
})